package com.zllkj.mm.api.net;


import rx.Observable;
import rx.Subscriber;
import rx.functions.Func1;

/**
 * 请求数据统一封装类
 */
public abstract class BaseEntity<T> implements Func1<BaseResultEntity<T>, T> {
    /**
     * 设置参数
     *
     * @param methods
     * @return
     */
    public abstract Observable getObservable(HttpService methods);

    /**
     * 设置回调sub
     *
     * @return
     */
    public abstract Subscriber getSubscirber();


    @Override
    public T call(BaseResultEntity<T> httpResult) {
        if ((!httpResult.getCode().equals("0000")) && (!httpResult.getCode().equals("1"))) {
            throw new HttpTimeException(httpResult.getMessage());
        }
        return httpResult.getResult();
    }
}

